//删除按钮
window.onload = function(){
	$(".address_smallbox .del").each(function(index,val){
		var delBthH = $(val).parents(".address_smallbox").height();
		$(val).height(delBthH);
	})
}

var winW = window.innerWidth;
var movePer = 96/750;//96为删除按钮的宽度
var moveDis = 0;
var moveDisY = 0;
var lastPos = 0;
var lastPosY = 0;

	$(".address_bigbox .address_smallbox").on("touchstart",function(e){
		$(".address_smallbox .del").each(function(index,val){
			var delBthH = $(val).parents(".address_smallbox").height();
			$(val).height(delBthH);
		})
		
		lastPos = e.originalEvent.targetTouches[0].clientX;
		lastPosY = e.originalEvent.targetTouches[0].clientY;
		moveDis = 0;
		moveDisY = 0;
	});
	
	$(".address_bigbox .address_smallbox").on("touchmove",function(e){
	var curPos = e.originalEvent.targetTouches[0].clientX;
	var curPosY = e.originalEvent.targetTouches[0].clientY;
	moveDis +=(curPos - lastPos);
	moveDisY += (curPosY - lastPosY);
	if(Math.abs(moveDisY)>10){
		console.log(111)
		moveDis = 0;
	}
	if(-moveDis>20){
		var dis = -1*movePer*winW;
		liMove(e,dis);
	}
	if(moveDis>5){
		liMove(e,0);
	}
	lastPos = curPos;
	lastPosY = curPosY;

})
//li移动函数	
function liMove(e,dis){
	var targetLi = $(e.target).parents(".address_smallbox");
	if(!targetLi){
		targetLi = $(".address_smallbox");
	}
	targetLi.css("transform","translateX("+dis+"px)");
	if(dis<0){
		targetLi.find(".del").show();
	}else{
		targetLi.find(".del").hide();
	}
}
//删除商品
var del = $(".del");
var	shoppingList = $(".shoppingList").find("li");
del.on("click",function(){
	$(this).parents(".address_smallbox").css("transform","translateX(100%)");
	$(this).parents(".address_smallbox").animate(
		{"opacity":0},
		200,
		"swing",
		function(){
			$(this).remove();
		}
	)
	
})